﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PrimaryAlgorithm.MoveZeroes
{
    class MainProject
    {
        static void Main(string[] args)
        {
            int[] nums = new int[] { 7, 1, 5, 3, 0, 4 };
            MoveZeroes(nums);
            foreach (var item in nums)
            {
                Console.WriteLine(item);

            }
            Console.ReadKey();
        }
        public static void MoveZeroes(int[] nums)
        {
            Queue<int> indexqQue = new Queue<int>();
            for (int i = 0; i < nums.Length; i++)
            {
                if (nums[i] != 0)
                {
                    indexqQue.Enqueue(nums[i]);
                }
            }
            for (int i = 0; i < nums.Length; i++)
            {
                if (indexqQue.Count>0)
                {
                    nums[i] = indexqQue.Dequeue();
                }
                else
                {
                    nums[i] = 0;
                }
            }
        }
    }
}
